package com.atguigu.spring6.iocxml.bean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserTest {
    public static void main(String[] args) {
       /*创建bean的方式*/

        /*第一种 根据id获取bean*/
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        User user1 = (User)context.getBean("user");
        System.out.println("根据id获取对象"+user1);

        /*第二种 根据类型获取bean*/
        User user2 = context.getBean(User.class);
        System.out.println("根据类型获取对象"+user2);

        /*第三种 根据id和类型获取bean*/
        User user3 = context.getBean("user",User.class);
        System.out.println("根据id和类型获取对象"+user3);
    }
}
